//package com.logistics.system.controller;
//
//import com.logistics.common.core.utils.poi.ExcelUtil;
//import com.logistics.common.core.web.controller.BaseController;
//import com.logistics.common.core.web.domain.AjaxResult;
//import com.logistics.common.core.web.page.TableDataInfo;
//import com.logistics.common.log.annotation.Log;
//import com.logistics.common.log.enums.BusinessType;
//import com.logistics.common.security.annotation.RequiresPermissions;
//import com.logistics.system.domain.PayTrade;
//import com.logistics.system.service.IContractsService;
//import com.logistics.system.service.IPayTradeService;
//import com.logistics.system.service.ITransportPlansService;
//import com.logistics.system.service.IWaybillsService;
//import org.springframework.amqp.rabbit.core.RabbitTemplate;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.*;
//
//import javax.servlet.http.HttpServletResponse;
//import java.util.List;
//
///**
// * 支付订单Controller
// *
// * @author logistics
// * @date 2024-06-23
// */
//@RestController
//@RequestMapping("/trade")
//public class PayTradeController extends BaseController
//{
//    @Autowired
//    private IPayTradeService payTradeService;
//    @Autowired
//    private ITransportPlansService transportPlansService;
//    @Autowired
//    private IWaybillsService waybillsService;
//    @Autowired
//    private IContractsService contractsService;
//
//    @Autowired
//    private RabbitTemplate rabbitTemplate;
//
//    /**
//     * 查询支付订单列表
//     */
//    @RequiresPermissions("logistics:trade:list")
//    @GetMapping("/list")
//    public TableDataInfo list(PayTrade payTrade)
//    {
//        startPage();
//        List<PayTrade> list = payTradeService.selectPayTradeList(payTrade);
//        return getDataTable(list);
//    }
//
//    /**
//     * 导出支付订单列表
//     */
//    @RequiresPermissions("logistics:trade:export")
//    @Log(title = "支付订单", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, PayTrade payTrade)
//    {
//        List<PayTrade> list = payTradeService.selectPayTradeList(payTrade);
//        ExcelUtil<PayTrade> util = new ExcelUtil<PayTrade>(PayTrade.class);
//        util.exportExcel(response, list, "支付订单数据");
//    }
//
//    /**
//     * 获取支付订单详细信息
//     */
//    @RequiresPermissions("logistics:trade:query")
//    @GetMapping(value = "/{tradeId}")
//    public AjaxResult getInfo(@PathVariable("tradeId") Long tradeId)
//    {
//        return success(payTradeService.selectPayTradeByTradeId(tradeId));
//    }
//
//    /**
//     * 新增支付订单
//     */
//    @RequiresPermissions("logistics:trade:add")
//    @Log(title = "支付订单", businessType = BusinessType.INSERT)
//    @PostMapping
//    public AjaxResult add(@RequestBody PayTrade payTrade)
//    {
////        Waybills waybills = waybillsService.selectWaybillsByWaybillId((payTrade.getWaybillId()));
////        if(waybills.getWaybillStatus().equals(Constants.WAYBILL_STATUS_3)){
////            return AjaxResult.error("运单状态不是已完成，无法创建订单");
////        }
////        waybills.setWaybillStatus(Constants.WAYBILL_STATUS_3);
////        waybillsService.updateWaybills(waybills);
////
////
////        Long contractId=transportPlansService.selectContractIdByWaybillId((payTrade.getWaybillId()));
////        Contracts contracts = contractsService.selectContractsByContractId(contractId);
////        contracts.setContractStatus(Constants.CONTRACTS_STATUS_3);
////        contractsService.updateContracts(contracts);
////
////        Long planId=waybillsService.selectTransportPlanIdByWaybillId((payTrade.getWaybillId()));
////        System.out.println(planId);
////        TransportPlans transportPlans = transportPlansService.selectTransportPlansByPlanId(planId);
////        transportPlans.setPlanStatus(Constants.PLAN_STATUS_2);
////        transportPlansService.updateTransportPlans(transportPlans);
//
//        return toAjax(payTradeService.insertPayTrade(payTrade));
//    }
//
//    /**
//     * 修改支付订单
//     */
//    @RequiresPermissions("logistics:trade:edit")
//    @Log(title = "支付订单", businessType = BusinessType.UPDATE)
//    @PutMapping
//    public AjaxResult edit(@RequestBody PayTrade payTrade)
//    {
//        return toAjax(payTradeService.updatePayTrade(payTrade));
//    }
//
//    /**
//     * 删除支付订单
//     */
//    @RequiresPermissions("logistics:trade:remove")
//    @Log(title = "支付订单", businessType = BusinessType.DELETE)
//	@DeleteMapping("/{tradeIds}")
//    public AjaxResult remove(@PathVariable Long[] tradeIds)
//    {
//        return toAjax(payTradeService.deletePayTradeByTradeIds(tradeIds));
//    }
//
//    /**
//     * 支付完成
//     */
//    @RequiresPermissions("system:trade:payTradeAdd")
//
//    @GetMapping("/payTradeAdd/{tradeId}")
//    public AjaxResult payTradeAdd(@PathVariable Long tradeId) {
//
//        // 队列名称
//        String queueName = "basic.queue1";
//        // 消息
//
//        PayTrade payTrade=payTradeService.selectPayTradeByTradeId(tradeId);
//        Long payerId=payTrade.getPayer();
//        Long payeeId=payTrade.getPayee();
//
//        String message = "支付成功";
//        // 发送消息
//        rabbitTemplate.convertAndSend(queueName,message);
//        System.out.println("11111");
//
//
//
//
////        return toAjax();
//        return null;
//    }
//}
